Data inladen

Baits<-read.table(file = "~/GitHub/vespa_analyses/Input/Baits_useful.txt", header=TRUE, sep="\t", na.strings=c(""," ","NA"))

Flights_incomplete<-read.table(file = "~/GitHub/vespa_analyses/Input/Flights_incomplete.txt", header=TRUE, sep="\t", na.strings=c(""," ","NA"))

Nests<-read.table(file = "~/GitHub/vespa_analyses/Input/Nests_useful.txt", header=TRUE, sep="\t", na.strings=c(""," ","NA"))

Shortind_incomplete<-read.table(file = "~/GitHub/vespa_analyses/Input/Shortind_incomplete.txt", header=TRUE, sep="\t", na.strings=c(""," ","NA"))

Shortpot_incomplete<-read.table(file = "~/GitHub/vespa_analyses/Input/Shortpot_incomplete.txt", header=TRUE, sep="\t", na.strings=c(""," ","NA"))

Individuals<-read.table(file = "~/GitHub/vespa_analyses/Input/Individuals.txt", header=TRUE, sep="\t", na.strings=c(""," ","NA"))

-incomplete wil zeggen dat de weergegevens nog niet volledig zijn. Ik wacht hiervoor op het KMI.

Aanpassingen datasets

# Overbodige kolommen wegdoen, foutje in excel
Flights_incomplete<-Flights_incomplete[1:(length(Flights_incomplete)-2)]
Shortind_incomplete<-Shortind_incomplete[1:(length(Shortind_incomplete)-2)]
Shortpot_incomplete<-Shortpot_incomplete[1:(length(Shortpot_incomplete)-2)]

#Foerageersnelheid en vliegsnelheid (m/s) toevoegen aan tabel
Flights_incomplete$test_rule_of_thumb<-Flights_incomplete$Distance/(Flights_incomplete$Flighttime_min*60)
Shortind_incomplete$test_rule_of_thumb<-Shortind_incomplete$Distance/(Shortind_incomplete$Flighttime_min*60)
Shortpot_incomplete$test_rule_of_thumb<-Shortpot_incomplete$Distance/(Shortpot_incomplete$Flighttime_min*60)

Flights_incomplete$ForagingSpeed<-Flights_incomplete$Distance*2/(Flights_incomplete$Flighttime_min*60)
Shortind_incomplete$ForagingSpeed<-Shortind_incomplete$Distance*2/(Shortind_incomplete$Flighttime_min*60)
Shortpot_incomplete$ForagingSpeed<-Shortpot_incomplete$Distance*2/(Shortpot_incomplete$Flighttime_min*60)


## Urbanisatiecirkels per vliegtijd toevoegen
Flights_incomplete<-merge(Flights_incomplete, Baits[, c("NestID", "BaitID", "Urbanisation25m", "Urbanisation50m", "Urbanisation100m")], by=c("NestID", "BaitID"), all=TRUE)
Shortind_incomplete<-merge(Shortind_incomplete, Baits[, c("NestID", "BaitID", "Urbanisation25m", "Urbanisation50m", "Urbanisation100m")], by=c("NestID", "BaitID"))
Shortpot_incomplete<-merge(Shortpot_incomplete, Baits[, c("NestID", "BaitID", "Urbanisation25m", "Urbanisation50m", "Urbanisation100m")], by=c("NestID", "BaitID"))

## Urbanisatietrajecten per vliegtijd toevoegen
Flights_incomplete<-merge(Flights_incomplete, Baits[, c("NestID", "BaitID", "Traject25m", "Traject50m", "Traject100m")], by=c("NestID", "BaitID"), all=TRUE)
Shortind_incomplete<-merge(Shortind_incomplete, Baits[, c("NestID", "BaitID", "Traject25m", "Traject50m", "Traject100m")], by=c("NestID", "BaitID"))
Shortpot_incomplete<-merge(Shortpot_incomplete, Baits[, c("NestID", "BaitID", "Traject25m", "Traject50m", "Traject100m")], by=c("NestID", "BaitID"))

## Gewicht individu per vliegtijd toevoegen
Flights_incomplete<-merge(Flights_incomplete, Individuals[, c("NestID", "BaitID","ColorInd", "Weight_ind")], by=c("NestID", "BaitID", "ColorInd"), all=TRUE)
Shortind_incomplete<-merge(Shortind_incomplete, Individuals[, c("NestID", "BaitID", "ColorInd", "Weight_ind")], by=c("NestID", "BaitID", "ColorInd"))
Shortpot_incomplete<-merge(Shortpot_incomplete, Individuals[, c("NestID", "BaitID", "ColorInd","Weight_ind")], by=c("NestID", "BaitID", "ColorInd"))

## Nesthoogte per vliegtijd toevoegen
Flights_incomplete<-merge(Flights_incomplete, Nests[, c("NestID", "Height")], by=c("NestID"), all=TRUE)
Shortind_incomplete<-merge(Shortind_incomplete, Nests[, c("NestID", "Height")], by=c("NestID"))
Shortpot_incomplete<-merge(Shortpot_incomplete, Nests[, c("NestID", "Height")], by=c("NestID"))

library(ggplot2)
library(ggpubr)

Volgende datasets zijn gecreëerd:

Voorstel: Voor het model: Flight time ~ Distance zou ik de dataset vliegtijden per individu nemen (en eventueel per wiekpot?) Omdat we hiermee de theoretische regel 1min=100m kunnen verifiëren. De imkers nemen hiervoor altijd kortste meting

Voor modellen met weerparameters, gewicht, urbanisatie: Hiervoor zou ik telkens de hele dataset gebruiken omdat elke meting van deze factoren afhangt.

Datapunten op 2km weglaten

Deze metingen zijn nogal onzeker omdat deze waarnemingen ook van een ander nest kunnen komen. Was op 2km afstand en in Melle zijn toch redelijk wat nesten gevonden. Kans dat het van een nest is dat niet gevonden werd is groot.

Als de website van Vespawatch in orde is kan ik kijken of er eventueel een nest in de buurt is gevonden.

Voorlopig gaan we verder met de dataset zonder de outliers in Melle

library(dplyr)
## 
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
## 
##     filter, lag
## The following objects are masked from 'package:base':
## 
##     intersect, setdiff, setequal, union
Flights2_incomplete<-Flights_incomplete %>%  filter(NestID!=1)
Shortind2_incomplete<-Shortind_incomplete %>%  filter(NestID!=1)
Shortpot2_incomplete<-Shortpot_incomplete %>%  filter(NestID!=1)

Data exploratie

1) Flight Error vs Distance

Graphs

ggplot(Flights2_incomplete, aes(x=Distance, y=FlightError)) + geom_point(color="cadetblue2") + geom_smooth(method="lm", formula =y ~ x, se=TRUE, fullrange=FALSE, level=0.95, color="cadetblue") + ggtitle("All data")+ theme(plot.title = element_text(hjust = 0.5, size=10))
## Warning: Removed 9 rows containing non-finite values (`stat_smooth()`).
## Warning: Removed 9 rows containing missing values (`geom_point()`).

Model Output

library(circular)
## 
## Attaching package: 'circular'
## The following objects are masked from 'package:stats':
## 
##     sd, var
Errorcirc<-circular(Flights2_incomplete$FlightError, type=c("angles"), units=c("degrees"), rotation=c("clock"), zero=0)

lm.circular(Errorcirc, Flights2_incomplete$Distance, type=c("c-l"), init=c(1))
## 
## Call:
## lm.circular.cl(y = ..1, x = ..2, init = ..3)
## 
## 
##  Circular-Linear Regression 
## 
##  Coefficients:
##      Estimate Std. Error t value Pr(>|t|)   
## [1,]   0.3983     0.1326   3.005  0.00133 **
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
##  Log-Likelihood:  420.8 
## 
##  Summary: (mu in radians)
##   mu:  -167.6 ( 1.035 )  kappa:  12.72 ( 1.109 )
## p-values are approximated using normal distribution

Moet ik 1 invullen bij init? =“a vector with initial values of length equal to the columns of x”

2) ForagingSpeed vs Temperature

Graphs

Grafieken zonder outliers telkens voor de volgende datasets

  • volledige dataset

  • enkel kortste vliegtijden per individu

  • enkel kortste vliegtijden per wiekpot

Model Output

All data

Hoogsignificant

Normality niet ok!

Indien log(ForagingSpeed) ~ log(Temperature) wel! Shapiro test (p-value=0.2979)

Indien log(ForagingSpeed) ~ Temperature wel! Shapiro test (p-value=0.1341)

model_temp_all<-lm(ForagingSpeed ~ Temperature, na.action=na.exclude, data=Flights2_incomplete)
summary(model_temp_all)
## 
## Call:
## lm(formula = ForagingSpeed ~ Temperature, data = Flights2_incomplete, 
##     na.action = na.exclude)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -2.8197 -0.7096 -0.2606  0.7950  3.4308 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)    
## (Intercept) -1.08514    0.31735  -3.419 0.000776 ***
## Temperature  0.19308    0.01673  11.543  < 2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 1.173 on 181 degrees of freedom
##   (78 observations deleted due to missingness)
## Multiple R-squared:  0.424,  Adjusted R-squared:  0.4208 
## F-statistic: 133.2 on 1 and 181 DF,  p-value: < 2.2e-16
res<-residuals(model_temp_all)
shapiro.test(res)
## 
##  Shapiro-Wilk normality test
## 
## data:  res
## W = 0.973, p-value = 0.001288
qqnorm(res)
qqline(res)

3) Flight time vs Distance + Temperature

Graph

library(knitr)
library(kableExtra)
## Warning in !is.null(rmarkdown::metadata$output) && rmarkdown::metadata$output
## %in% : 'length(x) = 2 > 1' in coercion to 'logical(1)'
## 
## Attaching package: 'kableExtra'
## The following object is masked from 'package:dplyr':
## 
##     group_rows
library("plot3D")

x <- Flights2_incomplete$Distance
y <- Flights2_incomplete$Temperature
z <- Flights2_incomplete$Flighttime_min

fit <- lm(z ~ x + y, na.action=na.exclude)
x.pred <- seq(min(x[!is.na(x)]), max(x[!is.na(x)]), length.out = 20)
y.pred <- seq(min(y[!is.na(y)]), max(y[!is.na(y)]), length.out = 20)
xy <- expand.grid( x = x.pred, y = y.pred)
z.pred <- matrix(predict(fit, newdata = xy), 
                 nrow = 20, ncol = 20)
fitpoints <- predict(fit)

scatter3D(x, y, z, pch = 19, cex = 0.6, colvar=FALSE, col="dodgerblue3", theta = 210, phi = 10, bty="u", col.panel ="grey93", expand =0.4, col.grid = "white", xlab = "Distance", ylab = "Temperature", zlab = "Flight time", surf = list(x = x.pred, y = y.pred, z = z.pred,  
facets = TRUE, col=ramp.col(col = c("dodgerblue4", "seagreen2"), n = 100, alpha=0.8), fit = fitpoints, border="black"),main = "Flight time vs Distance + Temperature")

Met plotly

Had met deze link problemen met expand.grid https://stackoverflow.com/questions/38331198/add-regression-plane-to-3d-scatter-plot-in-plotly

Dan maar grid dat van hierboven gebruikt, maar nu klopt er precies iets niet? Alle datapunten liggen boven het oppervlak.

library(plotly)
## 
## Attaching package: 'plotly'
## The following object is masked from 'package:circular':
## 
##     wind
## The following object is masked from 'package:ggplot2':
## 
##     last_plot
## The following object is masked from 'package:stats':
## 
##     filter
## The following object is masked from 'package:graphics':
## 
##     layout
library(tidyverse)
## ── Attaching packages
## ───────────────────────────────────────
## tidyverse 1.3.2 ──
## ✔ tibble  3.1.8     ✔ purrr   1.0.1
## ✔ tidyr   1.2.1     ✔ stringr 1.5.0
## ✔ readr   2.1.4     ✔ forcats 1.0.0
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ plotly::filter()         masks dplyr::filter(), stats::filter()
## ✖ kableExtra::group_rows() masks dplyr::group_rows()
## ✖ dplyr::lag()             masks stats::lag()
FlightsNoNA<-Flights2_incomplete %>%  filter(Flighttime_min!="NA")
FlightsNoNA<-FlightsNoNA %>%  filter(Temperature!="NA")


fig <- plot_ly(FlightsNoNA, x = ~Distance, y = ~Temperature, z = ~Flighttime_min, size=1)
fig <- fig %>% add_markers()
fig <- fig %>% layout(scene = list(xaxis = list(title = 'Distance'),
                     yaxis = list(title = 'Temperature'),
                     zaxis = list(title = 'Flight time (min)')))


p2 <- add_trace(p = fig,
                z = z.pred,
                x = seq(2100, 0, by = -100),
                y = seq(0, 30, by = 10),
                type = "surface")
p2

Model Ouput

All data

Distance en temperatuur hoogsignificant

Normality niet ok!

Poisson en log/sqrt werken niet

model_tempdist_all<-lm(Flighttime_min ~ Distance + Temperature, na.action=na.exclude, data=Flights2_incomplete)
summary(model_tempdist_all)
## 
## Call:
## lm(formula = Flighttime_min ~ Distance + Temperature, data = Flights2_incomplete, 
##     na.action = na.exclude)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -2.5147 -1.2599 -0.5980  0.6598 12.9039 
## 
## Coefficients:
##               Estimate Std. Error t value Pr(>|t|)    
## (Intercept)  5.3044798  0.6078392   8.727 1.74e-15 ***
## Distance     0.0074393  0.0008063   9.226  < 2e-16 ***
## Temperature -0.1929755  0.0356478  -5.413 1.96e-07 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 2.216 on 180 degrees of freedom
##   (78 observations deleted due to missingness)
## Multiple R-squared:  0.3254, Adjusted R-squared:  0.3179 
## F-statistic: 43.41 on 2 and 180 DF,  p-value: 4.131e-16
res<-residuals(model_tempdist_all)
shapiro.test(res)
## 
##  Shapiro-Wilk normality test
## 
## data:  res
## W = 0.74053, p-value < 2.2e-16
qqnorm(res)
qqline(res)

4) ForagingSpeed vs Height

Graphs

plot10<-ggplot(Flights2_incomplete, aes(x=Height, y=ForagingSpeed)) + geom_point(color="burlywood3") + geom_smooth(method="lm", formula =y ~ x, se=TRUE, fullrange=FALSE, level=0.95, color="chocolate4") + ggtitle("All data")+ theme(plot.title = element_text(hjust = 0.5, size=10))

plot11<-ggplot(Shortind2_incomplete, aes(x=Height, y=ForagingSpeed)) + geom_point(color="burlywood3") + geom_smooth(method="lm", formula =y ~ x, se=TRUE, fullrange=FALSE, level=0.95, color="chocolate4") + ggtitle("Shortest per ind.") + theme(plot.title = element_text(hjust = 0.5, size=10))

plot12<-ggplot(Shortpot2_incomplete, aes(x=Height, y=ForagingSpeed)) + geom_point(color="burlywood3") + geom_smooth(method="lm", formula =y ~ x,  se=TRUE, fullrange=FALSE, level=0.95, color="chocolate4") + ggtitle("Shortest per jar")+ theme(plot.title = element_text(hjust = 0.5, size=10))

ggarrange(plot10, plot11, plot12 + rremove("x.text"), 
          labels = c("A", "B", "C"),
          ncol = 2, nrow = 2)

Model Ouput

All data

Hoogsignificant

Normality niet ok!

Poisson en log/sqrt werken niet

model_height_all<-lm(ForagingSpeed ~ Height, na.action=na.exclude, data=Flights2_incomplete)
summary(model_height_all)
## 
## Call:
## lm(formula = ForagingSpeed ~ Height, data = Flights2_incomplete, 
##     na.action = na.exclude)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -2.7394 -1.1905 -0.1984  1.0376  8.3218 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)    
## (Intercept)  1.98208    0.22241   8.912  < 2e-16 ***
## Height       0.04264    0.01206   3.536 0.000495 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 1.508 on 221 degrees of freedom
##   (38 observations deleted due to missingness)
## Multiple R-squared:  0.05355,    Adjusted R-squared:  0.04926 
## F-statistic:  12.5 on 1 and 221 DF,  p-value: 0.0004949
res<-residuals(model_height_all)
shapiro.test(res)
## 
##  Shapiro-Wilk normality test
## 
## data:  res
## W = 0.93885, p-value = 4.793e-08
qqnorm(res)
qqline(res)

5) Flight time vs Distance + Height

Graphs

Height = height of the nest

x <- Flights2_incomplete$Distance
y <- Flights2_incomplete$Height
z <- Flights2_incomplete$Flighttime_min

fit <- lm(z ~ x + y, na.action=na.exclude)
x.pred <- seq(min(x[!is.na(x)]), max(x[!is.na(x)]), length.out = 20)
y.pred <- seq(min(y[!is.na(y)]), max(y[!is.na(y)]), length.out = 20)
xy <- expand.grid( x = x.pred, y = y.pred)
z.pred <- matrix(predict(fit, newdata = xy), 
                 nrow = 20, ncol = 20)
fitpoints <- predict(fit)

scatter3D(x, y, z, pch = 19, cex = 0.6, colvar=FALSE, col="dodgerblue3", theta = 40, phi = 15, bty="u", col.panel ="grey93", expand =0.4, col.grid = "white", xlab = "Distance", ylab = "Height", zlab = "Flight time", surf = list(x = x.pred, y = y.pred, z = z.pred,  
facets = TRUE, col=ramp.col(col = c("dodgerblue4", "seagreen2"), n = 100, alpha=0.8), fit = fitpoints, border="black"),main = "Flight time vs Distance + Height")

Model Output

All data

model_distheight_all<-lm(Flighttime_min ~ Distance + Height , na.action=na.exclude, data=Flights2_incomplete)
summary(model_distheight_all)
## 
## Call:
## lm(formula = Flighttime_min ~ Distance + Height, data = Flights2_incomplete, 
##     na.action = na.exclude)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -4.8389 -1.2579 -0.7078  0.6378 13.6933 
## 
## Coefficients:
##               Estimate Std. Error t value Pr(>|t|)    
## (Intercept)  3.2142938  0.3686312   8.720 6.91e-16 ***
## Distance     0.0058864  0.0005858  10.048  < 2e-16 ***
## Height      -0.0634323  0.0183671  -3.454 0.000663 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 2.284 on 220 degrees of freedom
##   (38 observations deleted due to missingness)
## Multiple R-squared:  0.3267, Adjusted R-squared:  0.3206 
## F-statistic: 53.38 on 2 and 220 DF,  p-value: < 2.2e-16

Height effect blijkt toch significant. In de negatieve zin weliswaar. Hoe hoger het nest hoe minder lang hij erover doet. Zou het omgekeerde verwachten..

Voorstel: Model volgens Pythagoras?

Hoogsignificant

model_distheight2_all<-lm(Flighttime_min ~ sqrt(I(Distance^2) + I(Height^2)) , na.action=na.exclude, data=Flights2_incomplete)
summary(model_distheight2_all)
## 
## Call:
## lm(formula = Flighttime_min ~ sqrt(I(Distance^2) + I(Height^2)), 
##     data = Flights2_incomplete, na.action = na.exclude)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -3.7477 -1.2641 -0.7849  0.3824 13.8647 
## 
## Coefficients:
##                                    Estimate Std. Error t value Pr(>|t|)    
## (Intercept)                       2.2285116  0.2429953   9.171   <2e-16 ***
## sqrt(I(Distance^2) + I(Height^2)) 0.0056853  0.0005979   9.508   <2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 2.339 on 221 degrees of freedom
##   (38 observations deleted due to missingness)
## Multiple R-squared:  0.2903, Adjusted R-squared:  0.2871 
## F-statistic: 90.41 on 1 and 221 DF,  p-value: < 2.2e-16

6) ForagingSpeed vs Cloudcoverage

Graphs

plot13<-ggplot(Flights2_incomplete, aes(x=Cloudcoverage, y=ForagingSpeed)) + geom_point(color="lightblue") + geom_smooth(method="lm", formula =y ~ x, se=TRUE, fullrange=FALSE, level=0.95, color="darkblue") + ggtitle("All data")+ theme(plot.title = element_text(hjust = 0.5, size=10))

plot14<-ggplot(Shortind2_incomplete, aes(x=Cloudcoverage, y=ForagingSpeed)) + geom_point(color="lightblue") + geom_smooth(method="lm", formula =y ~ x, se=TRUE, fullrange=FALSE, level=0.95, color="darkblue") + ggtitle("Shortest per ind.") + theme(plot.title = element_text(hjust = 0.5, size=10))

plot15<-ggplot(Shortpot2_incomplete, aes(x=Cloudcoverage, y=ForagingSpeed)) + geom_point(color="lightblue") + geom_smooth(method="lm", formula =y ~ x,  se=TRUE, fullrange=FALSE, level=0.95, color="darkblue") + ggtitle("Shortest per jar")+ theme(plot.title = element_text(hjust = 0.5, size=10))

ggarrange(plot13, plot14, plot15 + rremove("x.text"), 
          labels = c("A", "B", "C"),
          ncol = 2, nrow = 2)

Model Ouput

All data

Hoogsignificant

Normality niet ok!

Poisson en log/sqrt werken niet

model_cloud_all<-lm(ForagingSpeed ~ Cloudcoverage, na.action=na.exclude, data=Flights2_incomplete)
summary(model_cloud_all)
## 
## Call:
## lm(formula = ForagingSpeed ~ Cloudcoverage, data = Flights2_incomplete, 
##     na.action = na.exclude)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -2.1845 -1.2324 -0.3021  1.1390  3.8835 
## 
## Coefficients:
##               Estimate Std. Error t value Pr(>|t|)    
## (Intercept)     2.5341     0.1966  12.888   <2e-16 ***
## Cloudcoverage  -0.5491     0.3208  -1.711   0.0891 .  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 1.491 on 150 degrees of freedom
##   (109 observations deleted due to missingness)
## Multiple R-squared:  0.01915,    Adjusted R-squared:  0.01261 
## F-statistic: 2.929 on 1 and 150 DF,  p-value: 0.08906
res<-residuals(model_cloud_all)
shapiro.test(res)
## 
##  Shapiro-Wilk normality test
## 
## data:  res
## W = 0.94063, p-value = 5.166e-06
qqnorm(res)
qqline(res)

7) ForagingSpeed vs Weight individual

Graphs

plot16<-ggplot(Flights2_incomplete, aes(x=Weight_ind, y=ForagingSpeed)) + geom_point(color="plum") + geom_smooth(method="lm", formula =y ~ x, se=TRUE, fullrange=FALSE, level=0.95, color="darkorchid4") + ggtitle("All data")+ theme(plot.title = element_text(hjust = 0.5, size=10))

plot17<-ggplot(Shortind2_incomplete, aes(x=Weight_ind, y=ForagingSpeed)) + geom_point(color="plum") + geom_smooth(method="lm", formula =y ~ x, se=TRUE, fullrange=FALSE, level=0.95, color="darkorchid4") + ggtitle("Shortest per ind.") + theme(plot.title = element_text(hjust = 0.5, size=10))

plot18<-ggplot(Shortpot2_incomplete, aes(x=Weight_ind, y=ForagingSpeed)) + geom_point(color="plum") + geom_smooth(method="lm", formula =y ~ x,  se=TRUE, fullrange=FALSE, level=0.95, color="darkorchid4") + ggtitle("Shortest per jar")+ theme(plot.title = element_text(hjust = 0.5, size=10))

ggarrange(plot16, plot17, plot18 + rremove("x.text"), 
          labels = c("A", "B", "C"),
          ncol = 2, nrow = 2)

Model Output

All data

Niet significant

Normality niet ok!

sqrt(ForagingSpeed) ~ sqrt(Weight_ind) met Poisson nipt wel. Shapiro test (p-value=0.06463)

model_weight_all<-lm(ForagingSpeed ~ Weight_ind, na.action=na.exclude, data=Flights2_incomplete)
summary(model_weight_all)
## 
## Call:
## lm(formula = ForagingSpeed ~ Weight_ind, data = Flights2_incomplete, 
##     na.action = na.exclude)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -1.8995 -0.9467 -0.2375  1.0092  2.5308 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)    
## (Intercept)   2.5517     0.5969   4.275 4.88e-05 ***
## Weight_ind   -1.0014     1.7162  -0.583    0.561    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 1.117 on 87 degrees of freedom
##   (172 observations deleted due to missingness)
## Multiple R-squared:  0.003898,   Adjusted R-squared:  -0.007551 
## F-statistic: 0.3405 on 1 and 87 DF,  p-value: 0.5611
res<-residuals(model_weight_all)
shapiro.test(res)
## 
##  Shapiro-Wilk normality test
## 
## data:  res
## W = 0.94628, p-value = 0.001071
qqnorm(res)
qqline(res)

8.1) ForagingSpeed vs Windspeed

Graphs

Telkens voor de modellen

ForagingSpeed ~ Windspeed

ForagingSpeed ~ Windspeed²

plot19<-ggplot(Flights2_incomplete, aes(x=Windspeed, y=ForagingSpeed)) + geom_point(color="khaki3") + geom_smooth(method="lm", formula =y ~ x, se=TRUE, fullrange=FALSE, level=0.95, color="olivedrab") + ggtitle("All data")+ theme(plot.title = element_text(hjust = 0.5, size=10))

plot20<-ggplot(Shortind_incomplete, aes(x=Windspeed, y=ForagingSpeed)) + geom_point(color="khaki3") + geom_smooth(method="lm", formula =y ~ x, se=TRUE, fullrange=FALSE, level=0.95, color="olivedrab") + ggtitle("Shortest per ind.") + theme(plot.title = element_text(hjust = 0.5, size=10))

plot21<-ggplot(Shortpot_incomplete, aes(x=Windspeed, y=ForagingSpeed)) + geom_point(color="khaki3") + geom_smooth(method="lm", formula =y ~ x,  se=TRUE, fullrange=FALSE, level=0.95, color="olivedrab") + ggtitle("Shortest per jar")+ theme(plot.title = element_text(hjust = 0.5, size=10))

plot22<-ggplot(Flights2_incomplete, aes(x=Windspeed, y=ForagingSpeed)) + geom_point(color="khaki3") + geom_smooth(method="lm", formula =y ~ I(x^2), se=TRUE, fullrange=FALSE, level=0.95, color="olivedrab") + ggtitle("All data")+ theme(plot.title = element_text(hjust = 0.5, size=10))

plot23<-ggplot(Shortind_incomplete, aes(x=Windspeed, y=ForagingSpeed)) + geom_point(color="khaki3") + geom_smooth(method="lm", formula =y ~ I(x^2), se=TRUE, fullrange=FALSE, level=0.95, color="olivedrab") + ggtitle("Shortest per ind.") + theme(plot.title = element_text(hjust = 0.5, size=10))

plot24<-ggplot(Shortpot_incomplete, aes(x=Windspeed, y=ForagingSpeed)) + geom_point(color="khaki3") + geom_smooth(method="lm", formula =y ~ I(x^2),  se=TRUE, fullrange=FALSE, level=0.95, color="olivedrab") + ggtitle("Shortest per jar")+ theme(plot.title = element_text(hjust = 0.5, size=10))

ggarrange(plot19, plot20, plot21, plot22, plot23, plot24 + rremove("x.text"), 
          labels = c("A", "B", "C"),
          ncol = 3, nrow = 2)

Model Output

All data Beide modellen significant

Normality niet ok!

Poisson en log/sqrt werken niet

model_wind_all<-lm(ForagingSpeed ~ Windspeed, na.action=na.exclude, data=Flights2_incomplete)
summary(model_wind_all)
## 
## Call:
## lm(formula = ForagingSpeed ~ Windspeed, data = Flights2_incomplete, 
##     na.action = na.exclude)
## 
## Residuals:
##    Min     1Q Median     3Q    Max 
## -2.772 -1.127 -0.292  1.009  4.390 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)    
## (Intercept)   3.2272     0.2644  12.204  < 2e-16 ***
## Windspeed    -0.3667     0.1129  -3.249  0.00139 ** 
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 1.514 on 172 degrees of freedom
##   (87 observations deleted due to missingness)
## Multiple R-squared:  0.05783,    Adjusted R-squared:  0.05236 
## F-statistic: 10.56 on 1 and 172 DF,  p-value: 0.001392
model_wind2_all<-lm(ForagingSpeed ~ I(Windspeed^2), na.action=na.exclude, data=Flights2_incomplete)
summary(model_wind2_all)
## 
## Call:
## lm(formula = ForagingSpeed ~ I(Windspeed^2), data = Flights2_incomplete, 
##     na.action = na.exclude)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -2.4834 -1.1718 -0.2343  1.0190  4.3176 
## 
## Coefficients:
##                Estimate Std. Error t value Pr(>|t|)    
## (Intercept)     2.86827    0.17828  16.089  < 2e-16 ***
## I(Windspeed^2) -0.07563    0.02479  -3.051  0.00265 ** 
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 1.519 on 172 degrees of freedom
##   (87 observations deleted due to missingness)
## Multiple R-squared:  0.05133,    Adjusted R-squared:  0.04581 
## F-statistic: 9.306 on 1 and 172 DF,  p-value: 0.002646
res<-residuals(model_wind_all)
shapiro.test(res)
## 
##  Shapiro-Wilk normality test
## 
## data:  res
## W = 0.96386, p-value = 0.0001765
qqnorm(res)
qqline(res)

res<-residuals(model_wind2_all)
shapiro.test(res)
## 
##  Shapiro-Wilk normality test
## 
## data:  res
## W = 0.96413, p-value = 0.0001883
qqnorm(res)
qqline(res)

8.2) ForagingSpeed vs Windspeed | afhankelijk van de windrichting

Hiervoor werd telkens voor elke meting nagegaan of de hoornaar met meewind (tailwind), tegenwind (upwind) of loodrechte wind (perpendicular) te maken had. Dit volgens de formules:

|𝜃flight −𝜃wind| ≤ 45 is tailwind

45 < |𝜃flight −𝜃wind|<135 is (quasi) perpendicular

|𝜃 flight −𝜃wind| ≥135 upwind

Voorstel Misschien kan ik tegenwind en meewind samenvoegen aangezien de hoornaar telkens heen en terug vliegt?

Graphs

ggplot(data=subset(Flights2_incomplete, !is.na(Wind)), aes(x= Wind, col=Wind, y=ForagingSpeed)) + geom_boxplot()
## Warning: Removed 6 rows containing non-finite values (`stat_boxplot()`).

ggplot(data=subset(Flights2_incomplete, !is.na(Wind)), aes(x= Windspeed, col=Wind, y=ForagingSpeed)) + geom_point() + facet_grid(~Wind) + geom_smooth(method="lm", formula = y ~ I(x^2), se=TRUE, fullrange=FALSE, level=0.95)
## Warning: Removed 6 rows containing non-finite values (`stat_smooth()`).
## Warning: Removed 6 rows containing missing values (`geom_point()`).

Model Output

Taiwind licht significant

Upwind significant, maar zeer lage R²

data_tailwind<-Flights2_incomplete %>%  filter(Wind!="tailwind")
data_perpendicular<-Flights2_incomplete %>%  filter(Wind!="perpendicular")
data_upwind<-Flights2_incomplete %>%  filter(Wind!="upwind")

model_tailwind<-lm(ForagingSpeed ~ I(Windspeed^2), na.action=na.exclude, data=data_tailwind)
summary(model_tailwind)
## 
## Call:
## lm(formula = ForagingSpeed ~ I(Windspeed^2), data = data_tailwind, 
##     na.action = na.exclude)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -2.2414 -1.1136 -0.3614  0.9290  4.5141 
## 
## Coefficients:
##                Estimate Std. Error t value Pr(>|t|)    
## (Intercept)     2.62575    0.20359  12.897   <2e-16 ***
## I(Windspeed^2) -0.06413    0.02670  -2.401   0.0177 *  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 1.539 on 138 degrees of freedom
##   (4 observations deleted due to missingness)
## Multiple R-squared:  0.04011,    Adjusted R-squared:  0.03315 
## F-statistic: 5.766 on 1 and 138 DF,  p-value: 0.01767
model_perpendicular<-lm(ForagingSpeed ~ I(Windspeed^2), na.action=na.exclude, data=data_perpendicular)
summary(model_perpendicular)
## 
## Call:
## lm(formula = ForagingSpeed ~ I(Windspeed^2), data = data_perpendicular, 
##     na.action = na.exclude)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -2.1745 -1.3644 -0.2466  1.1510  4.5741 
## 
## Coefficients:
##                Estimate Std. Error t value Pr(>|t|)    
## (Intercept)     2.22570    0.34457   6.459 2.89e-08 ***
## I(Windspeed^2)  0.02088    0.05736   0.364    0.717    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 1.679 on 55 degrees of freedom
##   (4 observations deleted due to missingness)
## Multiple R-squared:  0.002404,   Adjusted R-squared:  -0.01573 
## F-statistic: 0.1325 on 1 and 55 DF,  p-value: 0.7172
model_upwind<-lm(ForagingSpeed ~ I(Windspeed^2), na.action=na.exclude, data=data_upwind)
summary(model_upwind)
## 
## Call:
## lm(formula = ForagingSpeed ~ I(Windspeed^2), data = data_upwind, 
##     na.action = na.exclude)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -2.6756 -1.1091 -0.1986  0.9393  3.5654 
## 
## Coefficients:
##                Estimate Std. Error t value Pr(>|t|)    
## (Intercept)     3.06119    0.19631  15.594  < 2e-16 ***
## I(Windspeed^2) -0.09290    0.02585  -3.594 0.000469 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 1.365 on 123 degrees of freedom
##   (4 observations deleted due to missingness)
## Multiple R-squared:  0.09504,    Adjusted R-squared:  0.08769 
## F-statistic: 12.92 on 1 and 123 DF,  p-value: 0.0004692

9) Flight error vs urbanisation (25m, 50m, 100m)

Flight error is the difference between the actual angle from the bait to the nest and the flight direction I measured.

Urbanisatiecirkels

Graphs

plot25<-ggplot(data=Flights2_incomplete, aes(x=Urbanisation25m, y=FlightError)) + geom_point() + geom_smooth(method="lm", formula =y ~ x, se=TRUE, fullrange=FALSE, level=0.95) + ggtitle("Urbanisation circles 25m")+ theme(plot.title = element_text(hjust = 0.5, size=10))

plot26<-ggplot(data=Flights2_incomplete, aes(x=Urbanisation50m, y=FlightError)) + geom_point()+ geom_smooth(method="lm", formula =y ~ x, se=TRUE, fullrange=FALSE, level=0.95) + ggtitle("Urbanisation circles 50m")+ theme(plot.title = element_text(hjust = 0.5, size=10))

plot27<-ggplot(data=Flights2_incomplete, aes(x=Urbanisation100m, y=FlightError)) + geom_point()+ geom_smooth(method="lm", formula =y ~ x, se=TRUE, fullrange=FALSE, level=0.95) + ggtitle("Urbanisation circles 100m")+ theme(plot.title = element_text(hjust = 0.5, size=10))

ggarrange(plot25, plot26, plot27 + rremove("x.text"), 
          labels = c("A", "B", "C"),
          ncol = 2, nrow = 2)
## Warning: Removed 9 rows containing non-finite values (`stat_smooth()`).
## Warning: Removed 9 rows containing missing values (`geom_point()`).
## Warning: Removed 9 rows containing non-finite values (`stat_smooth()`).
## Warning: Removed 9 rows containing missing values (`geom_point()`).
## Warning: Removed 9 rows containing non-finite values (`stat_smooth()`).
## Warning: Removed 9 rows containing missing values (`geom_point()`).

Model Output

library(circular)
Errorcirc<-circular(Flights2_incomplete$FlightError, type=c("angles"), units=c("degrees"), rotation=c("clock"), zero=0)

lm.circular(Errorcirc, Flights2_incomplete$Urbanisation25m, type=c("c-l"), init=c(1))
## 
## Call:
## lm.circular.cl(y = ..1, x = ..2, init = ..3)
## 
## 
##  Circular-Linear Regression 
## 
##  Coefficients:
##      Estimate Std. Error t value Pr(>|t|)
## [1,]  0.02084    0.03946   0.528    0.299
## 
##  Log-Likelihood:  418.9 
## 
##  Summary: (mu in radians)
##   mu:  14.89 ( 1.043 )  kappa:  12.54 ( 1.093 )
## p-values are approximated using normal distribution

Moet ik 1 invullen bij init? “a vector with initial values of length equal to the columns of x”

lm.circular(Errorcirc, Flights2_incomplete$Urbanisation50m, type=c("c-l"), init=c(1))
## 
## Call:
## lm.circular.cl(y = ..1, x = ..2, init = ..3)
## 
## 
##  Circular-Linear Regression 
## 
##  Coefficients:
##      Estimate Std. Error t value Pr(>|t|)
## [1,]  0.03933    0.03923   1.002    0.158
## 
##  Log-Likelihood:  419 
## 
##  Summary: (mu in radians)
##   mu:  15.3 ( 1.042 )  kappa:  12.56 ( 1.094 )
## p-values are approximated using normal distribution

Niet significant

lm.circular(Errorcirc, Flights2_incomplete$Urbanisation100m, type=c("c-l"), init=c(1))
## 
## Call:
## lm.circular.cl(y = ..1, x = ..2, init = ..3)
## 
## 
##  Circular-Linear Regression 
## 
##  Coefficients:
##      Estimate Std. Error t value Pr(>|t|)    
## [1,]  0.14864    0.03812   3.899 4.82e-05 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
##  Log-Likelihood:  421.3 
## 
##  Summary: (mu in radians)
##   mu:  17.8 ( 1.033 )  kappa:  12.77 ( 1.113 )
## p-values are approximated using normal distribution

Significant

Urbanisatietrajecten

Graphs

plot28<-ggplot(data=subset(Flights2_incomplete, !is.na(Observer)), aes(x=Traject25m, y=FlightError)) + geom_point(col="hotpink1") + geom_smooth(method="lm", formula =y ~ x, se=TRUE, fullrange=FALSE, level=0.95, color="violetred4")

plot29<-ggplot(data=subset(Flights2_incomplete, !is.na(Observer)), aes(x=Traject50m, y=FlightError)) + geom_point(col="hotpink1") + geom_smooth(method="lm", formula =y ~ x , se=TRUE, fullrange=FALSE, level=0.95, color="violetred4")

plot30<-ggplot(data=subset(Flights2_incomplete, !is.na(Observer)), aes(x=Traject100m, y=FlightError)) + geom_point(col="hotpink1")+ geom_smooth(method="lm", formula =y ~ x, se=TRUE, fullrange=FALSE, level=0.95, color="violetred4")

ggarrange(plot28, plot29, plot30 + rremove("x.text"), 
          labels = c("A", "B", "C"),
          ncol = 2, nrow = 2)
## Warning: Removed 9 rows containing non-finite values (`stat_smooth()`).
## Warning: Removed 9 rows containing missing values (`geom_point()`).
## Warning: Removed 9 rows containing non-finite values (`stat_smooth()`).
## Warning: Removed 9 rows containing missing values (`geom_point()`).
## Warning: Removed 9 rows containing non-finite values (`stat_smooth()`).
## Warning: Removed 9 rows containing missing values (`geom_point()`).

Model Output

Traject25m, Traject50m en Traject100m significant

library(circular)
Errorcirc<-circular(Flights2_incomplete$FlightError, type=c("angles"), units=c("degrees"), rotation=c("clock"), zero=0)

lm.circular(Errorcirc, Flights2_incomplete$Traject25m, type=c("c-l"), init=c(1))
## 
## Call:
## lm.circular.cl(y = ..1, x = ..2, init = ..3)
## 
## 
##  Circular-Linear Regression 
## 
##  Coefficients:
##      Estimate Std. Error t value Pr(>|t|)    
## [1,]  0.16459    0.03502     4.7  1.3e-06 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
##  Log-Likelihood:  423 
## 
##  Summary: (mu in radians)
##   mu:  18.32 ( 1.026 )  kappa:  12.94 ( 1.128 )
## p-values are approximated using normal distribution
lm.circular(Errorcirc, Flights2_incomplete$Traject50m, type=c("c-l"), init=c(1))
## 
## Call:
## lm.circular.cl(y = ..1, x = ..2, init = ..3)
## 
## 
##  Circular-Linear Regression 
## 
##  Coefficients:
##      Estimate Std. Error t value Pr(>|t|)    
## [1,]   0.1231     0.0357   3.448 0.000282 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
##  Log-Likelihood:  420.9 
## 
##  Summary: (mu in radians)
##   mu:  17.4 ( 1.035 )  kappa:  12.73 ( 1.11 )
## p-values are approximated using normal distribution
lm.circular(Errorcirc, Flights2_incomplete$Traject100m, type=c("c-l"), init=c(1))
## 
## Call:
## lm.circular.cl(y = ..1, x = ..2, init = ..3)
## 
## 
##  Circular-Linear Regression 
## 
##  Coefficients:
##      Estimate Std. Error t value Pr(>|t|)    
## [1,]  0.15022    0.03505   4.286 9.11e-06 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
##  Log-Likelihood:  421.6 
## 
##  Summary: (mu in radians)
##   mu:  18.19 ( 1.031 )  kappa:  12.81 ( 1.116 )
## p-values are approximated using normal distribution

Significant

10) ForagingSpeed vs Urbanisation

Graphs

Urbanisatiecirkels niet berekend, meteen trajecten genomen want die zijn betere maatstaf

Alle data

plot31<-ggplot(data=subset(Flights2_incomplete, !is.na(Observer)), aes(x=Traject25m, y=ForagingSpeed)) + geom_point(col="slateblue1") + geom_smooth(method="lm", formula =y ~ x, se=TRUE, fullrange=FALSE, level=0.95, color="slateblue4")
               
plot32<-ggplot(data=subset(Flights2_incomplete, !is.na(Observer)), aes(x=Traject50m, y=ForagingSpeed)) + geom_point(col="slateblue1") + geom_smooth(method="lm", formula =y ~ x, se=TRUE, fullrange=FALSE, level=0.95, color="slateblue4")

plot33<-ggplot(data=subset(Flights2_incomplete, !is.na(Observer)), aes(x=Traject100m, y=ForagingSpeed)) + geom_point(col="slateblue1") + geom_smooth(method="lm", formula =y ~ x, se=TRUE, fullrange=FALSE, level=0.95, color="slateblue4")

ggarrange(plot31, plot32, plot33 + rremove("x.text"), 
          labels = c("A", "B", "C"),
          ncol = 2, nrow = 2)
## Warning: Removed 26 rows containing non-finite values (`stat_smooth()`).
## Warning: Removed 26 rows containing missing values (`geom_point()`).
## Warning: Removed 26 rows containing non-finite values (`stat_smooth()`).
## Warning: Removed 26 rows containing missing values (`geom_point()`).
## Warning: Removed 26 rows containing non-finite values (`stat_smooth()`).
## Warning: Removed 26 rows containing missing values (`geom_point()`).

Shortest per individual

plot34<-ggplot(data=subset(Shortind_incomplete, !is.na(Observer)), aes(x=Traject25m, y=ForagingSpeed)) + geom_point(col="lemonchiffon3") + geom_smooth(method="lm", formula =y ~ x, se=TRUE, fullrange=FALSE, level=0.95, color="lemonchiffon4")
               
plot35<-ggplot(data=subset(Shortind_incomplete, !is.na(Observer)), aes(x=Traject50m, y=ForagingSpeed)) + geom_point(col="lemonchiffon3") +
geom_smooth(method="lm", formula =y ~ x, se=TRUE, fullrange=FALSE, level=0.95, color="lemonchiffon4")

plot36<-ggplot(data=subset(Shortind_incomplete, !is.na(Observer)), aes(x=Traject100m, y=ForagingSpeed)) + geom_point(col="lemonchiffon3") + geom_smooth(method="lm", formula =y ~ x, se=TRUE, fullrange=FALSE, level=0.95, color="lemonchiffon4")

ggarrange(plot34, plot35, plot36 + rremove("x.text"), 
          labels = c("A", "B", "C"),
          ncol = 2, nrow = 2)

Model Output

All data All significant

Normality not ok!

met Poisson wel normaal! Shapiro-test p-value= 0.3992

model_urb25_all<-lm(ForagingSpeed ~ Traject25m, na.action=na.exclude, data=Flights2_incomplete)
summary(model_urb25_all)
## 
## Call:
## lm(formula = ForagingSpeed ~ Traject25m, data = Flights2_incomplete, 
##     na.action = na.exclude)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -3.4703 -0.7871 -0.0828  0.7738  6.6260 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)    
## (Intercept)   3.6910     0.1379   26.76   <2e-16 ***
## Traject25m   -5.5106     0.5340  -10.32   <2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 1.318 on 233 degrees of freedom
##   (26 observations deleted due to missingness)
## Multiple R-squared:  0.3137, Adjusted R-squared:  0.3107 
## F-statistic: 106.5 on 1 and 233 DF,  p-value: < 2.2e-16
model_urb50_all<-lm(ForagingSpeed ~ Traject50m, na.action=na.exclude, data=Flights2_incomplete)
summary(model_urb50_all)
## 
## Call:
## lm(formula = ForagingSpeed ~ Traject50m, data = Flights2_incomplete, 
##     na.action = na.exclude)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -3.0798 -0.7869 -0.0795  0.8003  6.5421 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)    
## (Intercept)   3.8511     0.1420   27.12   <2e-16 ***
## Traject50m   -6.1889     0.5569  -11.11   <2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 1.286 on 233 degrees of freedom
##   (26 observations deleted due to missingness)
## Multiple R-squared:  0.3464, Adjusted R-squared:  0.3436 
## F-statistic: 123.5 on 1 and 233 DF,  p-value: < 2.2e-16
model_urb100_all<-lm(ForagingSpeed ~ Traject100m, na.action=na.exclude, data=Flights2_incomplete)
summary(model_urb100_all)
## 
## Call:
## lm(formula = ForagingSpeed ~ Traject100m, data = Flights2_incomplete, 
##     na.action = na.exclude)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -2.9544 -0.8053 -0.1753  0.8174  6.4851 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)    
## (Intercept)   3.9952     0.1497   26.69   <2e-16 ***
## Traject100m  -6.5645     0.5765  -11.39   <2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 1.275 on 233 degrees of freedom
##   (26 observations deleted due to missingness)
## Multiple R-squared:  0.3575, Adjusted R-squared:  0.3548 
## F-statistic: 129.7 on 1 and 233 DF,  p-value: < 2.2e-16
#Residuals voor Traject100m
res<-residuals(model_urb100_all)
shapiro.test(res)
## 
##  Shapiro-Wilk normality test
## 
## data:  res
## W = 0.9675, p-value = 3.322e-05
qqnorm(res)
qqline(res)

Shortest per individual

Allemaal significant

model_urb25_ind<-lm(ForagingSpeed ~ Traject25m, na.action=na.exclude, data=Shortind_incomplete)
summary(model_urb25_ind)
## 
## Call:
## lm(formula = ForagingSpeed ~ Traject25m, data = Shortind_incomplete, 
##     na.action = na.exclude)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -3.8480 -0.9978  0.0167  0.7126  6.2478 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)    
## (Intercept)   4.0691     0.2213  18.383   <2e-16 ***
## Traject25m   -4.3231     1.2337  -3.504    7e-04 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 1.549 on 95 degrees of freedom
## Multiple R-squared:  0.1145, Adjusted R-squared:  0.1051 
## F-statistic: 12.28 on 1 and 95 DF,  p-value: 0.0007002
model_urb50_ind<-lm(ForagingSpeed ~ Traject50m, na.action=na.exclude, data=Shortind_incomplete)
summary(model_urb50_ind)
## 
## Call:
## lm(formula = ForagingSpeed ~ Traject50m, data = Shortind_incomplete, 
##     na.action = na.exclude)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -3.5064 -0.9661 -0.0851  0.6831  6.1960 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)    
## (Intercept)   4.1832     0.2272  18.415  < 2e-16 ***
## Traject50m   -5.0598     1.2748  -3.969  0.00014 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 1.524 on 95 degrees of freedom
## Multiple R-squared:  0.1422, Adjusted R-squared:  0.1332 
## F-statistic: 15.75 on 1 and 95 DF,  p-value: 0.0001401
model_urb100_ind<-lm(ForagingSpeed ~ Traject100m, na.action=na.exclude, data=Shortind_incomplete)
summary(model_urb100_ind)
## 
## Call:
## lm(formula = ForagingSpeed ~ Traject100m, data = Shortind_incomplete, 
##     na.action = na.exclude)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -3.3694 -0.9967 -0.0850  0.7380  6.2148 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)    
## (Intercept)   4.2295     0.2358  17.933  < 2e-16 ***
## Traject100m  -5.1207     1.2901  -3.969  0.00014 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 1.524 on 95 degrees of freedom
## Multiple R-squared:  0.1422, Adjusted R-squared:  0.1332 
## F-statistic: 15.75 on 1 and 95 DF,  p-value: 0.0001401

11) ForagingSpeed vs Temperatuur + Urbanisation

Aangezien temperatuur en urbanisatie de beste predictoren zijn kunnen we ze eens samen in een model steken.

x <- Flights2_incomplete$Temperature
y <- Flights2_incomplete$Traject100m
z <- Flights2_incomplete$ForagingSpeed

fit <- lm(z ~ x + y, na.action=na.exclude)
x.pred <- seq(min(x[!is.na(x)]), max(x[!is.na(x)]), length.out = 20)
y.pred <- seq(min(y[!is.na(y)]), max(y[!is.na(y)]), length.out = 20)
xy <- expand.grid( x = x.pred, y = y.pred)
z.pred <- matrix(predict(fit, newdata = xy), 
                 nrow = 20, ncol = 20)
fitpoints <- predict(fit)

scatter3D(x, y, z, pch = 19, cex = 0.6, colvar=FALSE, col="dodgerblue3", theta = 210, phi = 10, bty="u", col.panel ="grey93", expand =0.4, col.grid = "white", xlab = "Temperature", ylab = "Urbanisation (Traject100m)", zlab = "Flight Speed", surf = list(x = x.pred, y = y.pred, z = z.pred,  
facets = TRUE, col=ramp.col(col = c("dodgerblue4", "seagreen2"), n = 100, alpha=0.8), fit = fitpoints, border="black"),main = "Flight Speed vs Temperature + Urbanisation")

Allemaal significant! Traject 100m hoogste R²: 0.4914

model_4_all<-lm(ForagingSpeed ~ Temperature + Traject25m, na.action=na.exclude, data=Flights2_incomplete)
summary(model_4_all)
## 
## Call:
## lm(formula = ForagingSpeed ~ Temperature + Traject25m, data = Flights2_incomplete, 
##     na.action = na.exclude)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -2.8161 -0.6685 -0.0619  0.6084  3.1989 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)    
## (Intercept)  1.13598    0.63594   1.786   0.0757 .  
## Temperature  0.11423    0.02551   4.477 1.34e-05 ***
## Traject25m  -3.27294    0.82221  -3.981 9.96e-05 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 1.127 on 180 degrees of freedom
##   (78 observations deleted due to missingness)
## Multiple R-squared:  0.4706, Adjusted R-squared:  0.4647 
## F-statistic: 80.01 on 2 and 180 DF,  p-value: < 2.2e-16
model_5_all<-lm(ForagingSpeed ~ Temperature + Traject50m, na.action=na.exclude, data=Flights2_incomplete)
summary(model_5_all)
## 
## Call:
## lm(formula = ForagingSpeed ~ Temperature + Traject50m, data = Flights2_incomplete, 
##     na.action = na.exclude)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -2.9005 -0.6330 -0.0565  0.6201  3.1846 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)    
## (Intercept)  1.49113    0.63681   2.342   0.0203 *  
## Temperature  0.10421    0.02503   4.163 4.86e-05 ***
## Traject50m  -3.96756    0.86416  -4.591 8.25e-06 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 1.113 on 180 degrees of freedom
##   (78 observations deleted due to missingness)
## Multiple R-squared:  0.4844, Adjusted R-squared:  0.4787 
## F-statistic: 84.55 on 2 and 180 DF,  p-value: < 2.2e-16
model_6_all<-lm(ForagingSpeed ~ Temperature + Traject100m, na.action=na.exclude, data=Flights2_incomplete)
summary(model_6_all)
## 
## Call:
## lm(formula = ForagingSpeed ~ Temperature + Traject100m, data = Flights2_incomplete, 
##     na.action = na.exclude)
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -2.94370 -0.63064 -0.09026  0.65454  3.11185 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)    
## (Intercept)  1.88673    0.65334   2.888 0.004355 ** 
## Temperature  0.09470    0.02483   3.814 0.000188 ***
## Traject100m -4.67106    0.91432  -5.109 8.22e-07 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 1.099 on 180 degrees of freedom
##   (78 observations deleted due to missingness)
## Multiple R-squared:  0.497,  Adjusted R-squared:  0.4914 
## F-statistic: 88.91 on 2 and 180 DF,  p-value: < 2.2e-16

Varpart

library(vegan) varpart(Flights2_incomplete$Flighttime_min, ~Distance, ~Temperatuur, ~Windspeed, na.action=na.exclude, data= Flights2_incomplete) Probleem met NA

TO DO - circulaire statistiek verder uitwerken ?

Statistische modellen probeersels

# Model kiezen
library(car)
## Loading required package: carData
## 
## Attaching package: 'car'
## The following object is masked from 'package:purrr':
## 
##     some
## The following object is masked from 'package:dplyr':
## 
##     recode
library(carData)
library(leaps)
select1<-regsubsets(ForagingSpeed ~ Temperature + Cloudcoverage + I(Windspeed^2) + Weight_ind + Traject100m, na.action=na.exclude, data=Flights2_incomplete, nbest=3)
summary(select1)
## Subset selection object
## Call: regsubsets.formula(ForagingSpeed ~ Temperature + Cloudcoverage + 
##     I(Windspeed^2) + Weight_ind + Traject100m, na.action = na.exclude, 
##     data = Flights2_incomplete, nbest = 3)
## 5 Variables  (and intercept)
##                Forced in Forced out
## Temperature        FALSE      FALSE
## Cloudcoverage      FALSE      FALSE
## I(Windspeed^2)     FALSE      FALSE
## Weight_ind         FALSE      FALSE
## Traject100m        FALSE      FALSE
## 3 subsets of each size up to 5
## Selection Algorithm: exhaustive
##          Temperature Cloudcoverage I(Windspeed^2) Weight_ind Traject100m
## 1  ( 1 ) " "         " "           " "            " "        "*"        
## 1  ( 2 ) "*"         " "           " "            " "        " "        
## 1  ( 3 ) " "         " "           "*"            " "        " "        
## 2  ( 1 ) " "         "*"           " "            " "        "*"        
## 2  ( 2 ) "*"         "*"           " "            " "        " "        
## 2  ( 3 ) " "         " "           " "            "*"        "*"        
## 3  ( 1 ) "*"         "*"           " "            " "        "*"        
## 3  ( 2 ) " "         "*"           "*"            " "        "*"        
## 3  ( 3 ) " "         "*"           " "            "*"        "*"        
## 4  ( 1 ) "*"         "*"           " "            "*"        "*"        
## 4  ( 2 ) "*"         "*"           "*"            " "        "*"        
## 4  ( 3 ) " "         "*"           "*"            "*"        "*"        
## 5  ( 1 ) "*"         "*"           "*"            "*"        "*"
plot(select1, scale="adjr2")

select2<-regsubsets(ForagingSpeed ~ Temperature + Cloudcoverage + Windspeed + Weight_ind + Traject100m +
Traject100m*Temperature + Traject100m*Cloudcoverage + Traject100m*Windspeed + Traject100m*Weight_ind + Temperature*Cloudcoverage + Temperature*Windspeed + Temperature*Weight_ind + Cloudcoverage*Windspeed + Cloudcoverage*Weight_ind + Windspeed*Weight_ind, na.action=na.exclude, data=Flights2_incomplete, nbest=3)
summary(select2)
## Subset selection object
## Call: regsubsets.formula(ForagingSpeed ~ Temperature + Cloudcoverage + 
##     Windspeed + Weight_ind + Traject100m + Traject100m * Temperature + 
##     Traject100m * Cloudcoverage + Traject100m * Windspeed + Traject100m * 
##     Weight_ind + Temperature * Cloudcoverage + Temperature * 
##     Windspeed + Temperature * Weight_ind + Cloudcoverage * Windspeed + 
##     Cloudcoverage * Weight_ind + Windspeed * Weight_ind, na.action = na.exclude, 
##     data = Flights2_incomplete, nbest = 3)
## 15 Variables  (and intercept)
##                           Forced in Forced out
## Temperature                   FALSE      FALSE
## Cloudcoverage                 FALSE      FALSE
## Windspeed                     FALSE      FALSE
## Weight_ind                    FALSE      FALSE
## Traject100m                   FALSE      FALSE
## Temperature:Traject100m       FALSE      FALSE
## Cloudcoverage:Traject100m     FALSE      FALSE
## Windspeed:Traject100m         FALSE      FALSE
## Weight_ind:Traject100m        FALSE      FALSE
## Temperature:Cloudcoverage     FALSE      FALSE
## Temperature:Windspeed         FALSE      FALSE
## Temperature:Weight_ind        FALSE      FALSE
## Cloudcoverage:Windspeed       FALSE      FALSE
## Cloudcoverage:Weight_ind      FALSE      FALSE
## Windspeed:Weight_ind          FALSE      FALSE
## 3 subsets of each size up to 8
## Selection Algorithm: exhaustive
##          Temperature Cloudcoverage Windspeed Weight_ind Traject100m
## 1  ( 1 ) " "         " "           " "       " "        "*"        
## 1  ( 2 ) " "         " "           " "       " "        " "        
## 1  ( 3 ) "*"         " "           " "       " "        " "        
## 2  ( 1 ) " "         " "           " "       " "        "*"        
## 2  ( 2 ) " "         "*"           " "       " "        "*"        
## 2  ( 3 ) " "         " "           " "       " "        "*"        
## 3  ( 1 ) " "         " "           " "       " "        "*"        
## 3  ( 2 ) " "         " "           " "       " "        "*"        
## 3  ( 3 ) " "         " "           " "       " "        "*"        
## 4  ( 1 ) " "         " "           "*"       " "        "*"        
## 4  ( 2 ) " "         " "           "*"       " "        "*"        
## 4  ( 3 ) " "         "*"           "*"       " "        "*"        
## 5  ( 1 ) " "         " "           " "       " "        "*"        
## 5  ( 2 ) "*"         " "           " "       " "        "*"        
## 5  ( 3 ) " "         " "           " "       " "        "*"        
## 6  ( 1 ) " "         " "           " "       " "        "*"        
## 6  ( 2 ) " "         " "           " "       " "        "*"        
## 6  ( 3 ) " "         " "           " "       "*"        "*"        
## 7  ( 1 ) " "         "*"           " "       " "        "*"        
## 7  ( 2 ) " "         "*"           " "       " "        "*"        
## 7  ( 3 ) " "         "*"           " "       " "        "*"        
## 8  ( 1 ) "*"         " "           "*"       "*"        " "        
## 8  ( 2 ) " "         "*"           " "       " "        "*"        
## 8  ( 3 ) " "         "*"           " "       " "        "*"        
##          Temperature:Traject100m Cloudcoverage:Traject100m
## 1  ( 1 ) " "                     " "                      
## 1  ( 2 ) " "                     " "                      
## 1  ( 3 ) " "                     " "                      
## 2  ( 1 ) " "                     " "                      
## 2  ( 2 ) " "                     " "                      
## 2  ( 3 ) " "                     " "                      
## 3  ( 1 ) " "                     " "                      
## 3  ( 2 ) " "                     " "                      
## 3  ( 3 ) " "                     " "                      
## 4  ( 1 ) " "                     " "                      
## 4  ( 2 ) " "                     " "                      
## 4  ( 3 ) " "                     " "                      
## 5  ( 1 ) "*"                     " "                      
## 5  ( 2 ) " "                     " "                      
## 5  ( 3 ) "*"                     " "                      
## 6  ( 1 ) "*"                     " "                      
## 6  ( 2 ) "*"                     " "                      
## 6  ( 3 ) "*"                     " "                      
## 7  ( 1 ) "*"                     "*"                      
## 7  ( 2 ) "*"                     " "                      
## 7  ( 3 ) " "                     " "                      
## 8  ( 1 ) " "                     " "                      
## 8  ( 2 ) "*"                     "*"                      
## 8  ( 3 ) " "                     " "                      
##          Windspeed:Traject100m Weight_ind:Traject100m Temperature:Cloudcoverage
## 1  ( 1 ) " "                   " "                    " "                      
## 1  ( 2 ) " "                   "*"                    " "                      
## 1  ( 3 ) " "                   " "                    " "                      
## 2  ( 1 ) " "                   " "                    "*"                      
## 2  ( 2 ) " "                   " "                    " "                      
## 2  ( 3 ) " "                   " "                    " "                      
## 3  ( 1 ) " "                   " "                    "*"                      
## 3  ( 2 ) " "                   " "                    "*"                      
## 3  ( 3 ) " "                   " "                    " "                      
## 4  ( 1 ) "*"                   " "                    " "                      
## 4  ( 2 ) "*"                   " "                    "*"                      
## 4  ( 3 ) "*"                   " "                    " "                      
## 5  ( 1 ) "*"                   " "                    "*"                      
## 5  ( 2 ) "*"                   " "                    "*"                      
## 5  ( 3 ) "*"                   " "                    " "                      
## 6  ( 1 ) "*"                   " "                    "*"                      
## 6  ( 2 ) "*"                   " "                    "*"                      
## 6  ( 3 ) "*"                   " "                    "*"                      
## 7  ( 1 ) "*"                   " "                    "*"                      
## 7  ( 2 ) "*"                   " "                    "*"                      
## 7  ( 3 ) "*"                   "*"                    "*"                      
## 8  ( 1 ) " "                   "*"                    "*"                      
## 8  ( 2 ) "*"                   " "                    "*"                      
## 8  ( 3 ) "*"                   "*"                    "*"                      
##          Temperature:Windspeed Temperature:Weight_ind Cloudcoverage:Windspeed
## 1  ( 1 ) " "                   " "                    " "                    
## 1  ( 2 ) " "                   " "                    " "                    
## 1  ( 3 ) " "                   " "                    " "                    
## 2  ( 1 ) " "                   " "                    " "                    
## 2  ( 2 ) " "                   " "                    " "                    
## 2  ( 3 ) " "                   " "                    " "                    
## 3  ( 1 ) "*"                   " "                    " "                    
## 3  ( 2 ) " "                   " "                    "*"                    
## 3  ( 3 ) " "                   "*"                    " "                    
## 4  ( 1 ) " "                   " "                    " "                    
## 4  ( 2 ) " "                   " "                    " "                    
## 4  ( 3 ) " "                   " "                    " "                    
## 5  ( 1 ) "*"                   " "                    " "                    
## 5  ( 2 ) "*"                   " "                    " "                    
## 5  ( 3 ) "*"                   " "                    " "                    
## 6  ( 1 ) "*"                   " "                    "*"                    
## 6  ( 2 ) "*"                   "*"                    " "                    
## 6  ( 3 ) "*"                   " "                    " "                    
## 7  ( 1 ) "*"                   " "                    " "                    
## 7  ( 2 ) "*"                   " "                    "*"                    
## 7  ( 3 ) " "                   " "                    "*"                    
## 8  ( 1 ) "*"                   "*"                    " "                    
## 8  ( 2 ) "*"                   " "                    "*"                    
## 8  ( 3 ) "*"                   " "                    "*"                    
##          Cloudcoverage:Weight_ind Windspeed:Weight_ind
## 1  ( 1 ) " "                      " "                 
## 1  ( 2 ) " "                      " "                 
## 1  ( 3 ) " "                      " "                 
## 2  ( 1 ) " "                      " "                 
## 2  ( 2 ) " "                      " "                 
## 2  ( 3 ) "*"                      " "                 
## 3  ( 1 ) " "                      " "                 
## 3  ( 2 ) " "                      " "                 
## 3  ( 3 ) "*"                      " "                 
## 4  ( 1 ) "*"                      " "                 
## 4  ( 2 ) " "                      " "                 
## 4  ( 3 ) " "                      " "                 
## 5  ( 1 ) " "                      " "                 
## 5  ( 2 ) " "                      " "                 
## 5  ( 3 ) "*"                      " "                 
## 6  ( 1 ) " "                      " "                 
## 6  ( 2 ) " "                      " "                 
## 6  ( 3 ) " "                      " "                 
## 7  ( 1 ) " "                      " "                 
## 7  ( 2 ) " "                      " "                 
## 7  ( 3 ) " "                      "*"                 
## 8  ( 1 ) " "                      "*"                 
## 8  ( 2 ) " "                      " "                 
## 8  ( 3 ) " "                      "*"
plot(select2, scale="adjr2")

Multicollinearity check

library(ggcorrplot)
library(car)

datacor<-Flights2_incomplete[, c("Temperature", "Cloudcoverage", "Windspeed", "Weight_ind", "Traject100m")]
source("~/GitHub/vespa_analyses/Input/HighstatLibV10.R") 
corvif(datacor)
## 
## 
## Variance inflation factors
## 
##                   GVIF
## Temperature   6.054309
## Cloudcoverage 1.354508
## Windspeed     1.330242
## Weight_ind    1.441363
## Traject100m   6.708611
cormat <- round(cor(datacor, use = "pairwise.complete.obs"), 2)
ggcorrplot(cormat, lab= TRUE, type = "lower", ggtheme = ggplot2::theme_gray,
   colors = c("#6D9EC1", "white", "#E46726"))

plot(Temperature~Traject100m, data=Flights2_incomplete)

Eerder toeval dat Temperature en Traject100m gecorreleeerd zijn?

##PCA

library(vegan)
## Loading required package: permute
## Loading required package: lattice
## This is vegan 2.6-4
library(missMDA)
library(FactoMineR)
datapca<-select(Flights2_incomplete, Cloudcoverage, Windspeed, Temperature, Weight_ind, Traject100m)
nb <- estim_ncpPCA(datapca, scale = TRUE)
comp<-imputePCA(datapca, ncp=2)
res<-PCA(comp$completeObs)